
let hui = document.querySelector("#hui");
let huiol = document.querySelectorAll("#hui>ol>li");
var down;
hui.addEventListener("touchstart", function (e) {
    down = e.changedTouches[0].clientX;
})
hui.addEventListener("touchend", function (e) {
    var up = e.changedTouches[0].clientX;
    if (up - down < 0) {
        this.firstElementChild.style.transition = "all 1s"
        this.firstElementChild.style.left = "-3.2rem";
        this.lastElementChild.lastElementChild.style.backgroundColor = "red";
        this.lastElementChild.firstElementChild.style.backgroundColor = "#555"
        console.log()
    } else {
        this.firstElementChild.style.transition = "all 1s"
        this.firstElementChild.style.left = "0px";
        this.lastElementChild.lastElementChild.style.backgroundColor = "#555";
        this.lastElementChild.firstElementChild.style.backgroundColor = "red"
    }

})


let jishi = document.querySelectorAll("#jishi>span");
function daojis() {
    let time = new Date();
    const start = new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1);

    let t = (start - time) / 1000;
    let shi = bu(parseInt(t / 3600));
    let fen = bu(parseInt(t % 3600 / 60));
    let miao = bu(parseInt(t % 60));
    jishi[0].innerText = shi;
    jishi[1].innerText = fen;
    jishi[2].innerText = miao;
    function bu(l) {
        return l < 10 ? "0" + l : l;
    }
}
setInterval(daojis, 500);




let aside = document.querySelector("aside");
let p = aside.offsetTop;
let header = document.querySelector(".header");
let kk = ojb(header).top
document.body.onscroll = function () {
    if (document.documentElement.scrollTop > p) {

        aside.style.visibility = "visible"
    } else {
        aside.style.visibility = "hidden"
    }

    if (document.documentElement.scrollTop > kk) {
        header.previousElementSibling.style.position = "fixed";
        header.previousElementSibling.style.zIndex = 22;
    } else {
        header.previousElementSibling.style.position = "static";
    }
}

function ojb(ele) {//传参数
    var l = t = 0;//设置两个绝对距离的计数器
    while (ele.offsetParent) {
        l += ele.offsetLeft + ele.offsetParent.clientLeft;
        t += ele.offsetTop + ele.offsetParent.clientTop;
        ele = ele.offsetParent
    }
    return {
        left: l,
        top: t
    }
}

